package cn.kb05;


import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
/*
 * @author
 * @Description
 * @date
 * */
public class TestMenu {
    public static void main(String[] args) {
        Menu menu = new Menu(1, "鱼香肉丝", 10, 2, "小行路");
        Menu menu1 = new Menu(2, "鱼香肉丝", 15, 3, "小行路6号");
        Menu menu2 = new Menu(3, "鱼香肉丝", 10, 2, "小行路8号");


        List list = new LinkedList();
        list.add(menu);
        list.add(menu1);
        list.add(menu2);
        list.add(menu2);

        System.out.println(list);

        //定义一个set集合来去重
        System.out.println("去重之后");
        HashSet set = new HashSet();
        LinkedList link = (LinkedList)list;
        set.addAll(link);
        System.out.println(set);

        //转成ArrayList进行遍历
        System.out.println("转成ArrayList来进行遍历");
        List arr = list;
        for (int i = 0; i < arr.size(); i++) {
            System.out.println(arr.get(i));


            List l = list;

            //增加

            System.out.println("增加后");
            System.out.println(l);

            //删除

            l.remove(2);
            System.out.println("删除后");
            System.out.println(list);
            //list.remove(new Character('h'));

            //修改元素
            l.add(menu1);
            System.out.println(l);
            System.out.println("修改后");
            l.set(3,menu1);
            System.out.println(list);

            //查找
            System.out.println("查找下标为1的元素");
            System.out.println(list.get(1));
        }
    }}



